/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
class Solution {
    int res = 0;
    int num = 0;
    public int kthLargest(TreeNode root, int k) {
        num = k;
        inorder(root);
        return res;
    }
    //右根左就是倒序
    private void inorder(TreeNode root) {
        if(null == root) {
            return;
        }
        if(num>0) {
            inorder(root.right);
            num--;
            if(num == 0) {
                res = root.val;
                return;
            }
            inorder(root.left);
        }
    }
}